/*
 * 文件名：IntegralConfigServiceImpl.java
 * 版权：Copyright by www.huawei.com
 * 描述：
 * 修改人：Administrator
 * 修改时间：2016年5月10日
 * 跟踪单号：
 * 修改单号：
 * 修改内容：
 */

package com.zcsy.manage.service.mall.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zcsy.manage.model.mall.IntegralConfig;
import com.zcsy.manage.persistence.mall.IntegralConfigDao;
import com.zcsy.manage.service.mall.IIntegralConfigService;

/**
 * @Title: IntegralConfigServiceImpl.java
 * @Package： com.zcsy.manage.service.mall.impl 
 * @Description: 积分配置服务层接口实现类
 * @author liuying 1075817474@qq.com
 * @Copyright: 2015 武汉中财数元信息技术有限公司 All rights reserved.
 * @date 2016年5月10日
 * @version 1.0
 * @see JDK1.7.0_75
 * @since
 */
@Service
public class IntegralConfigServiceImpl implements IIntegralConfigService{

	@Autowired
	private IntegralConfigDao integralConfigDao;
	
	/* (non-Javadoc)
	 * @see com.zcsy.manage.service.mall.IIntegralConfigService#insert(com.zcsy.manage.model.mall.IntegralConfig)
	 */
	@Override
	public int insert(IntegralConfig integralConfig) {
		return integralConfigDao.insert(integralConfig);
	}

	/* (non-Javadoc)
	 * @see com.zcsy.manage.service.mall.IIntegralConfigService#update(com.zcsy.manage.model.mall.IntegralConfig)
	 */
	@Override
	public int update(IntegralConfig integralConfig) {
		IntegralConfig oldConfig = integralConfigDao.selectByPrimaryKey(integralConfig.getId());
		
		oldConfig.setLabel(integralConfig.getLabel());
		oldConfig.setName(integralConfig.getName());
		oldConfig.setValue(integralConfig.getValue());
		oldConfig.setUpdateAccount(integralConfig.getUpdateAccount());
		oldConfig.setUpdateTime(integralConfig.getUpdateTime());
		
		return integralConfigDao.updateByPrimaryKey(oldConfig);
	}

	/* (non-Javadoc)
	 * @see com.zcsy.manage.service.mall.IIntegralConfigService#delete(java.lang.String)
	 */
	@Override
	public int delete(String id) {
		return integralConfigDao.deleteByPrimaryKey(id);
	}

	/* (non-Javadoc)
	 * @see com.zcsy.manage.service.mall.IIntegralConfigService#selectByPrimaryKey(java.lang.String)
	 */
	@Override
	public IntegralConfig selectByPrimaryKey(String id) {
		return integralConfigDao.selectByPrimaryKey(id);
	}

	/* (non-Javadoc)
	 * @see com.zcsy.manage.service.mall.IIntegralConfigService#selectByName(java.lang.String)
	 */
	@Override
	public IntegralConfig selectByName(String name) {
		return integralConfigDao.selectByName(name);
	}

	/* (non-Javadoc)
	 * @see com.zcsy.manage.service.mall.IIntegralConfigService#selectByKeyword(com.zcsy.manage.model.mall.IntegralConfig)
	 */
	@Override
	public List<IntegralConfig> selectByKeyword(IntegralConfig integralConfig) {
		return integralConfigDao.selectByKeyword(integralConfig);
	}
	@Override
	public Integer getIntegralValue (String description) {
        
        // 根据唯一标识name获取"投诉建议或报修"的积分配置信息
        IntegralConfig integralConfig = integralConfigDao.selectByName(description);
        // "投诉建议或报修"可获得的积分值
        Integer value = Integer.valueOf(integralConfig.getValue());
        
        return value;
    }

}
